package com.tuiyun.jxgl.dao;

// Generated Feb 1, 2013 4:10:46 PM by Hibernate Tools 3.4.0.CR1

import java.util.List;
import javax.naming.InitialContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.tuiyun.jxgl.bean.Msgtemplate;

import static org.hibernate.criterion.Example.create;

/**
 * Home object for domain model class Msgtemplate.
 * @see com.tuiyun.jxgl.Msgtemplate
 * @author Hibernate Tools
 */
public class MsgtemplateHome extends HibernateDaoSupport{

	private static final Log log = LogFactory.getLog(MsgtemplateHome.class);	

	public void persist(Msgtemplate transientInstance) {
		log.debug("persisting Msgtemplate instance");
		try {
			getHibernateTemplate().persist(transientInstance);
			log.debug("persist successful");
		} catch (RuntimeException re) {
			log.error("persist failed", re);
			throw re;
		}
	}

	public void attachDirty(Msgtemplate instance) {
		log.debug("attaching dirty Msgtemplate instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(Msgtemplate instance) {
		log.debug("attaching clean Msgtemplate instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void delete(Msgtemplate persistentInstance) {
		log.debug("deleting Msgtemplate instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public Msgtemplate merge(Msgtemplate detachedInstance) {
		log.debug("merging Msgtemplate instance");
		try {
			Msgtemplate result = (Msgtemplate) getHibernateTemplate().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public Msgtemplate findById(int id) {
		log.debug("getting Msgtemplate instance with id: " + id);
		try {
			Msgtemplate instance = (Msgtemplate) getHibernateTemplate().
					get("com.tuiyun.jxgl.bean.Msgtemplate", id);
			if (instance == null) {
				log.debug("get successful, no instance found");
			} else {
				log.debug("get successful, instance found");
			}
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List<Msgtemplate> findByExample(Msgtemplate instance) {
		log.debug("finding Msgtemplate instance by example");
		try {
			List<Msgtemplate> results = (List<Msgtemplate>) getHibernateTemplate().findByExample(instance);					
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}
}
